<template>
  <div class="app-container">
    <el-card style="border-radius: 10px">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="订单编号" prop="poCode">
            <el-input
              v-model="queryParams.poCode"
              placeholder="请输入订单编号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="供货日期" prop="recptDate">
            <el-date-picker clearable
                            v-model="queryParams.recptDate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="请选择入库日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="供应商名称" prop="vendorName">
            <el-input
              v-model="queryParams.vendorName"
              placeholder="请输入供应商名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="   ">
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    </el-card>
    <div style="height: 15px"></div>
    <el-card style="border-radius: 10px">
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table border v-loading="loading" :data="ReceiptVoucherList" >
      <el-table-column label="入库单编号" align="center" prop="recptCode" width="190">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="handleInfo(scope.row)"
            v-hasPermi="['mes:cg:receiptVoucher:query']"
          >{{scope.row.recptCode}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="订单编号" align="center" prop="poCode" width="190"></el-table-column>
      <el-table-column label="入库单名称" width="160" align="center" prop="recptName" :show-overflow-tooltip="true"/>
      <el-table-column label="入库日期" align="center" prop="recptDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.recptDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="供应商名称" width="160" align="center" prop="vendorName" :show-overflow-tooltip="true"/>
      <el-table-column label="采购单位" align="center" prop="purchase" :show-overflow-tooltip="true"/>
      <el-table-column label="入库人" align="center" prop="storagePersonnel"/>
      <el-table-column label="审核人" align="center" prop="reviewer"/>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-tooltip content="查看" placement="top">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-view"
              @click="handleInfo(scope.row)"
              v-hasPermi="['mes:cg:receiptVoucher:query']"
            >
            </el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <InfoView ref="infoView"></InfoView>

  </div>
</template>

<script>
import {getList } from "@/api/mes/cg/receiptvoucher";
import InfoView from "@/views/mes/cg/receiptvoucher/infoView.vue"

export default {
  name: "ReceiptVoucher",
  components: {
    InfoView
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购订单表格数据
      ReceiptVoucherList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        poCode: null,  recptDate: null, vendorName: null
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询采购订单列表 */
    getList() {
      this.loading = true;
      getList(this.queryParams).then(response => {
        this.ReceiptVoucherList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 查看按钮操作 */
    handleInfo(row) {
      this.$refs.infoView.open = true;
      this.$refs.infoView.title = '查看采购入库单';
      this.$refs.infoView.init(row.voucherId);
    }
  }
};
</script>
